import java.util.Stack;

class MyQueue {
    //用栈实现队列
    Stack<Integer> sta1;
    Stack<Integer> sta2;
    public MyQueue() {
        sta1=new Stack<>();
        sta2=new Stack<>();
    }

    public void push(int x) {
        sta1.push(x);
    }

    public int pop() {
        if (empty()){
            return -1;
        }
        if (sta2.empty()){
            while(!sta1.isEmpty()) {
                sta2.push(sta1.pop());
            }
        }
        return sta2.pop();
    }

    public int peek() {
        if (empty()){
            return -1;
        }
        if (sta2.empty()){
            while(!sta1.isEmpty()) {
                sta2.push(sta1.pop());
            }
        }

        return sta2.peek();
    }

    public boolean empty() {
        return sta1.empty()&&sta2.empty();
    }
}